<template>
    <div class="news-List">
                <!-- <p>这是newList.vue</p> -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for='items in getdataList' :key='items.id'>
                <router-link :to="'/home/newsInfo/'+items.id"> <!-- 把商品列表里的id传给详情页newsInfo -->
                    <img class="mui-media-object mui-pull-left" :src="items.img_url">
                    <div class="mui-media-body">
                        {{items.title}}
                        <p class='mui-ellipsis'>
                            <span>发表时间：{{items.add_time |timef}}</span><span>点击：{{items.click}} 次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>
<script>
import { Toast } from "mint-ui";
export default {
    data(){
        return {
            //用于接收后台传过来的值
            getdataList:[]
        }
    },
    created() {
        this.getList()
    },
    methods: {
        getList(){
            this.$http.get('api/getnewslist').then(function(data){
                // console.log(data.body.message);
                if(status==0){
                    this.getdataList=data.body.message;
                }else{
                    Toast('请求数据失败')
                }
                
            })
        }
    },
    //局部 格式化时间
    /* filters:{
        'timef':(addtime)=>{
            var data=new Date(addtime)
            var y=data.getFullYear();
            var m=data.getMonth()+1;
            var d=data.getDate();
            return `${y}--${m}--${d}`
        }


    } */
}
</script>
<style>
    .mui-ellipsis{
        display: flex;
        justify-content: space-between;
    }
</style>

